/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.agi.devsol.aplicacao.comum;

import javax.enterprise.context.Conversation;
import org.jmock.Expectations;
import org.jmock.Mockery;

/**
 *
 * @author rgrosz
 */
public class ConversationMocker {
    private Conversation conversation;
    
    private Mockery mockery;
    public ConversationMocker(Mockery mockery){
       this.mockery = mockery; 
    }
    
    public Conversation createMock(){
        conversation = mockery.mock(Conversation.class);
        Expectations exp = new Expectations(){{
            allowing(conversation).isTransient();
            will(returnValue(false));
            
            allowing(conversation).end();
            allowing(conversation).begin();
        }};
        mockery.checking(exp);
        return conversation;
    }
}
